{% extends "_layout.html" %}
{% import "component/forms.njk" as forms %}

{# 样式代码 #}
{% block style %}
<link href="/css/plugins/iCheck/custom.css" rel="stylesheet">
{% endblock %}

{# bodyd代码#}
{% block body %}
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加商品类型</h5>

                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t from" id="form" action="/product/category/edit" method="post" data-href="/product/category">
                    	{{ forms.hidden('id', data.id) }}
						{{ forms.text('名称', 'name', data.name, '请输入名称', 'required') }}
						{{ forms.text('排序', 'sort', data.sort, '请输入排序', 'required') }}

                        {{ forms.images(
                            label = '图标',
                            fileList = [{
                            name: 'icon',
                            value: data.icon,
                            url: ctx.helper.showImage(data.icon, 160, 160, 'fixed'),
                            text: ''
                            }]
                        )}}

						{{ forms.textarea('备注', 'remark', data.remark, '请输入备注') }}
                        {{ forms.submit() }}
                    </form>
                </div>
            </div>
        </div>

    </div>
{% endblock %}

{#js代码#}
{% block js %}
<script>
    $(function () {
        var e = "";
        $("#form").validate({
            rules: {
                name: "required",
                sort: {
                    required : true,
                    number: true
                }
            },
            messages: {
                name: {
                    required: e + "请输入名称"
                },
                sort: {
                    required : e + "请输入排序",
                    number: "请输入正确数字"
                }
            },
            submitHandler: function() {
              asyncSubmitForm($("#form"));
            }
        });

    });
</script>

{% endblock %}